﻿<UserControl x:Class="Plugins.UserControls.PresetSelector"
			 
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             
             xmlns:Converters="clr-namespace:Utils.Wpf.Converters;assembly=Utils"
             xmlns:UserControls="clr-namespace:Plugins.UserControls" Background="#1F1F1F"
             
             mc:Ignorable="d"
             
             d:DesignHeight="130" >
    
    <UserControl.Resources>
        <ResourceDictionary>
            <Converters:MultiplierConverter x:Key="MultiplierConverter" />
			
			<Style TargetType="Image">
				<Style.Triggers>
					<Trigger Property="Image.IsEnabled" Value="False">
						<Setter Property="Image.Opacity" Value="0.5" />
					</Trigger>
				</Style.Triggers>
			</Style>
			
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="..\PluginTheme.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="Auto" />
			<ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>    
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

		<TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" VerticalAlignment="Center" Text="Preset Selection" HorizontalAlignment="Center" x:Name="Header" Margin="6" />

		<TextBlock Grid.Row="1" Grid.Column="0" Text="Name:" Margin="3" VerticalAlignment="Bottom" IsEnabled="{Binding IsSaveEnabled, RelativeSource={RelativeSource AncestorType=UserControls:PresetSelector}}" />

		<TextBox Grid.Row="2" Grid.ColumnSpan="2" Text="{Binding PresetName, UpdateSourceTrigger=PropertyChanged}" Width="{Binding ActualWidth, ElementName=Header, Converter={StaticResource MultiplierConverter}, ConverterParameter=1.86}" Margin="1" PreviewKeyDown="TextBox_PreviewKeyDown" IsEnabled="{Binding IsSaveEnabled, RelativeSource={RelativeSource AncestorType=UserControls:PresetSelector}}" >
			<TextBox.ToolTip>
				<StackPanel>
					<TextBlock Foreground="Black" FontWeight="Bold" Text="Preset Name" />
					<TextBlock Foreground="Black" Text="The name of the preset to be saved. It cannot be duplicated" />
				</StackPanel>
			</TextBox.ToolTip>
		</TextBox>
		<Button Grid.Row="2" Grid.Column="2" Command="{Binding SaveCommand}" Margin="1" IsEnabled="{Binding IsSaveEnabled, RelativeSource={RelativeSource AncestorType=UserControls:PresetSelector}}" >
			<Button.ToolTip>
				<StackPanel>
					<TextBlock Foreground="Black" FontWeight="Bold" Text="Save" />
					<TextBlock Foreground="Black" Text="Saves the current settings and sets the preset as the current selected." />
				</StackPanel>
			</Button.ToolTip>
			<Image Source="..\Resources\Save.ico" Stretch="None" />
		</Button>
		
		<Border Grid.Row="3" Grid.ColumnSpan="3" BorderBrush="{StaticResource SelectedRowBrush}" Background="{StaticResource SelectedRowBrush}" BorderThickness="1" Margin="6,12,6,12" />
		
		<ComboBox Grid.Row="4" Grid.Column="0" ItemsSource="{Binding Presets}" SelectedItem="{Binding SelectedPreset, Mode=TwoWay}" DisplayMemberPath="Name" PreviewMouseDown="ComboBox_PreviewMouseDown" Width="{Binding ActualWidth, ElementName=Header, Converter={StaticResource MultiplierConverter}, ConverterParameter=1.6}" Margin="1" >
			<ComboBox.ToolTip>
                <StackPanel>
                    <TextBlock Foreground="Black" FontWeight="Bold" Text="Selected Preset" />
                    <TextBlock Foreground="Black" Text="The name of the preset to be loaded or deleted." />
                </StackPanel>
            </ComboBox.ToolTip>
        </ComboBox>
		<Button Grid.Row="4" Grid.Column="1" Command="{Binding LoadCommand}" Margin="1" >
			<Button.ToolTip>
				<StackPanel>
					<TextBlock Foreground="Black" FontWeight="Bold" Text="Load" />
					<TextBlock Foreground="Black" Text="Loads the currently selected preset." />
				</StackPanel>
			</Button.ToolTip>
			<Image Source="..\Resources\Load.ico" Stretch="None" />
		</Button>
		<Button Grid.Row="4" Grid.Column="2" Command="{Binding DeleteCommand}" Margin="1" >
			<Button.ToolTip>
				<StackPanel>
					<TextBlock Foreground="Black" FontWeight="Bold" Text="Delete" />
					<TextBlock Foreground="Black" Text="Deletes the currently selected preset. This action cannot be undone." />
				</StackPanel>
			</Button.ToolTip>
			<Image Source="..\Resources\Delete.ico" Stretch="None" />
		</Button>
	</Grid>
</UserControl>
